import cv2 as cv
import numpy as np


def trackbar_callback(value):
    print('value = ', value)


def show_window():
    win_name = 'src image'
    src_img = np.zeros((320, 640, 3), np.uint8)
    cv.imshow(win_name, src_img)
    cv.createTrackbar('R', win_name, 0, 255, trackbar_callback)
    cv.createTrackbar('G', win_name, 0, 255, trackbar_callback)
    cv.createTrackbar('B', win_name, 0, 255, trackbar_callback)

    while 1:
        r = cv.getTrackbarPos('R', win_name)
        g = cv.getTrackbarPos('G', win_name)
        b = cv.getTrackbarPos('B', win_name)

        src_img[:] = [b, g, r]
        cv.imshow(win_name, src_img)
        key = cv.waitKey(1)
        if key == 27:
            break


if __name__ == '__main__':
    show_window()
